﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Quartz;
using Quartz.Impl;
using System.IO;

/// <summary>
/// Summary description for ScheduleAction
/// </summary>
public static class ScheduleAction
{
    public static ISchedulerFactory sf;
    public static IScheduler sched;
    public static int strCurrent = 0;
    public static void runSchedule()
    {
        sf = new StdSchedulerFactory();
        sched = sf.GetScheduler();
        sched.Start();
    }
    public static void addJob()
    {
        strCurrent++;
        JobDetail job = new JobDetail("job" + strCurrent, "group1" + strCurrent, typeof(AutoSiteMaps));
        Trigger trigger = new CronTrigger("trigger" + strCurrent, "group1" + strCurrent, "job" + strCurrent, "group1" + strCurrent, Setting.CronExpression);/*"0/2 1 * * * ?"*/
        sched.AddJob(job, true);
        sched.ScheduleJob(trigger);
    }
    public static void startSchedule()
    {
        runSchedule();
        addJob();
    }
}